#include <iostream>
#include <vector>
#include <map>
using namespace std;
int main()
{
	int m, n, ans = 0; cin >> m >> n;
	map<int, int> hash;
	for (int i = 0; i < m; ++i) for (int j = 0; j < n; ++j) { int tmp; cin >> tmp; hash[tmp]++; }
	for (int i = 0; i < m; ++i) for (int j = 0; j < n; ++j) { int tmp; cin >> tmp; hash[tmp]--; }
	for (auto& e : hash) ans += e.second < 0 ? -e.second : 0;
	cout << ans;
	return 0;
}